package com.stockz.ui.swing.core.menu;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.stockz.ui.swing.widget.JMenuItem;

@Component 
public class ExitMenuItem extends JMenuItem implements ActionListener, InitializingBean{
	private static final long serialVersionUID = 6271922906220286681L;

	@Autowired
	private FileMenu fileMenu;
	
	public ExitMenuItem() {
		super("Exit",KeyEvent.VK_F4,ActionEvent.ALT_MASK,"exit.jpg");
		addActionListener(this);
	}
	
	@Override
	public void afterPropertiesSet() throws Exception {
		fileMenu.add(this);
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		System.exit(1);
	}
	
}
